package com.lemon.controller;


import com.lemon.domain.PageResult;
import com.lemon.domain.Result;
import com.lemon.domain.dto.OperationsDetailsDto;
import com.lemon.domain.dto.WarehouseOperationsDto;
import com.lemon.service.WarehouseOperationsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 仓内作业表 前端控制器
 * </p>
 *
 * @author author
 * @since 2025-09-08
 */
@RestController
@RequestMapping("/warehouse_operations")
public class WarehouseOperationsController {

    @Autowired
    private WarehouseOperationsService warehouseOperationsService;

    @GetMapping("/{id}")
    public Result getDetails(@PathVariable Long id) {
        List<OperationsDetailsDto> details = warehouseOperationsService.getDetails(id);
        return Result.success(details);
    }


    @DeleteMapping("/{id}")
    public Result deleteWarehouse(@PathVariable Long id) {
        warehouseOperationsService.deleteWarehouse(id);
        return Result.success();
    }

    @PutMapping("/change/{id}")
    public Result change(@PathVariable Long id){
        warehouseOperationsService.change(id);
        return Result.success();
    }

    @PutMapping("/confirm/{id}")
    public Result confirm(@PathVariable Long id){
        warehouseOperationsService.confirm(id);
        return Result.success();
    }

    @PostMapping
    public Result add(@RequestBody WarehouseOperationsDto dto){
        warehouseOperationsService.add(dto);
        return Result.success();
    }

    @GetMapping
    public Result getPage(Integer page, Integer pageSize,String jobCode){
        PageResult pageResult = warehouseOperationsService.getPage(page, pageSize, jobCode);
        return Result.success(pageResult);
    }
}
